package Builder;

public class Sandwich {
    private int Size;
    private boolean cheese;
    private boolean bacon;
    private boolean tomato;
    private boolean lettuce;

//    public Sandwich(int Size, boolean cheese, boolean bacon, boolean tomato, boolean lettuce){
//        this.Size = Size;
//        this.cheese = cheese;
//        this.bacon = bacon;
//        this.tomato = tomato;
//        this.lettuce = lettuce;
//    }
    public Sandwich(SandwichBuilder builder){
        this.Size = builder.getSize();
        this.cheese = builder.hasCheese();
        this.bacon = builder.hasBacon();
        this.tomato = builder.hasTomato();
        this.lettuce = builder.hasLettuce();
    }

    public String getDescription(){
        return "这是一个尺寸为" + Size +"的三明治，包含"
                +(cheese ? "奶酪" : "")
                +(bacon ? "培根" : "")
                +(tomato ? "西红柿" : "")
                +(lettuce ? "生菜" : "");
    }
}

class main{
    public static void main(String[] args) {
        Sandwich sandwich = new SandwichBuilder()
                .setSize(14)
                .addLettuce()
                .addBacon()
                .addCheese()
                .addTomato()
                .build();
        System.out.println(sandwich.getDescription());
    }
}


